package project.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DbConn {
	/**
	 * 获取连接方法
	 * 
	 * @return
	 */

	public static Connection getConn() {
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://数据库地址:端口/数据库名?useUnicode=true&characterEncoding=UTF-8", "用户名", "密码");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}

	public static void main(String[] args) {
		try {
			DbConn.getConn();
			System.out.println("测试");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
